home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Tele
/
C
/
Comet2.1.3.cpt
/
Comet
/
net_utils.asm
< prev
next >
Wrap
Assembly Source File
|
1989-12-13
|
1KB
|
69 lines
; Copyright Cornell University 1986. All rights are reserved.
;
; As of 4/10/86:
;
; 10/8/87 kevin replaced old cksum loop with a snazzy dbra loop
; 11/8/88 kevin made cksum loop faster by using 32 bit ops to hold carries
public _version
_version: dcb.w 1,10
; bswap(int) swaps the bytes in an int
public _swab
public _bswap
_swab:
_bswap:
move.b 4(a7),d0
move.b 5(a7),d1
lsl #8,d1
or.w d1,d0
rts
;
; _cksum(buf, len) performs an Internet type checksum. buf points to where
; the checksumming should begin, len is the number of 16 bit words
; to be summed. Returns the checksum. This is the Unix compatible
; version
;
public _cksum
_cksum:
move.l 4(a7),a0 ; a0 -> buffer
clr.l d0 ; d0 -> initial value for xsum
clr.l d2 ; d2 = 0
move.w 8(a7),d1 ; d1 -> length
bra start ; jump to dbra to start loop
lpchk:
move.w (a0)+,d2 d2 -> next word
add.l d2,d0 d0 += d2
start:
dbra d1,lpchk ;loop around
lpdone:
swap d0 ; switch so carries on bottom
move.w d0,d1
swap d0
add.w d1,d0 ; add carries back in
bcc.s no_carry
addq.w #1,d0 ; yet another carry occurred
no_carry:
rts ; all done
; byte swap a long
public _lswap
public _wswap
_lswap:
_wswap:
move.l 4(a7),d0
swap d0
rts